home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / I386 / IIS5_01.CAB / IIS_SimpleQuery_VBScript.asp < prev    next >
Encoding:
Text File  |  1999-07-21  |  1.2 KB  |  72 lines

  1. <%@ LANGUAGE = VBScript %>
  2. <%  Option Explicit        %>
  3.  
  4. <HTML>
  5.     <HEAD>
  6.         <TITLE>Simple ADO Query</TITLE>
  7.     </HEAD>
  8.  
  9.     <BODY BGCOLOR="White" topmargin="10" leftmargin="10">
  10.  
  11.         <!-- Display Header -->
  12.  
  13.         <font size="4" face="Arial, Helvetica">
  14.         <b>Simple ADO Query with ASP</b></font><br>
  15.     
  16.         <hr size="1" color="#000000">
  17.  
  18.         Contacts within the Authors Database:<br><br>
  19.  
  20.         <%
  21.             Dim oConn        
  22.             Dim oRs        
  23.             Dim filePath        
  24.             Dim Index        
  25.  
  26.             
  27.             ' Map authors database to physical path
  28.             filePath = Server.MapPath("authors.mdb")
  29.  
  30.  
  31.             ' Create ADO Connection Component to connect
  32.             ' with sample database
  33.             
  34.  
  35.             
  36.             Set oConn = Server.CreateObject("ADODB.Connection")
  37.             oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filePath
  38.             
  39.             
  40.             ' Execute a SQL query and store the results
  41.             ' within recordset
  42.             
  43.             Set oRs = oConn.Execute("SELECT * From authors")
  44.         %>
  45.  
  46.  
  47.         <TABLE border = 1>
  48.         <%  
  49.             Do while (Not oRs.eof) %>
  50.  
  51.                 <tr>
  52.                     <% For Index=0 to (oRs.fields.count-1) %>
  53.                         <TD VAlign=top><% = oRs(Index)%></TD>
  54.                     <% Next %>
  55.                 </tr>
  56.             
  57.                 <% oRs.MoveNext 
  58.             Loop 
  59.         %>
  60.  
  61.  
  62.         </TABLE>
  63.  
  64.  
  65.         <%   
  66.             oRs.close
  67.             oConn.close 
  68.         %>
  69.  
  70.     </BODY>
  71. </HTML>
  72.